home *** CD-ROM | disk | FTP | other *** search
/ C++ für Kids / C++ for kids.iso / SETUP / US / CBUILDER / DATA.Z / STDIO.H < prev    next >
C/C++ Source or Header  |  1997-02-13  |  21KB  |  506 lines

  1. /*  stdio.h
  2.  
  3.     Definitions for stream input/output.
  4.  
  5. */
  6.  
  7. /*
  8.  *      C/C++ Run Time Library - Version 8.0
  9.  *
  10.  *      Copyright (c) 1987, 1997 by Borland International
  11.  *      All Rights Reserved.
  12.  *
  13.  */
  14. /* $Revision:   8.20  $ */
  15.  
  16. #ifndef __STDIO_H
  17. #define __STDIO_H
  18.  
  19. #if !defined(___DEFS_H)
  20. #include <_defs.h>
  21. #endif
  22.  
  23. #if !defined(___NFILE_H)
  24. #include <_nfile.h>
  25. #endif
  26.  
  27. #ifndef NULL
  28. #include <_null.h>
  29. #endif
  30.  
  31.  
  32. #if !defined(RC_INVOKED)
  33.  
  34. #if defined(__STDC__)
  35. #pragma warn -nak
  36. #endif
  37.  
  38. #pragma pack(push, 1)
  39.  
  40. #endif  /* !RC_INVOKED */
  41.  
  42.  
  43. #ifndef _SIZE_T
  44. #define _SIZE_T
  45. typedef unsigned size_t;
  46. #endif
  47.  
  48. #ifndef __cplusplus
  49. #if !defined(_WCHAR_T) && !defined(_WCHAR_T_DEFINED)
  50. #define _WCHAR_T
  51. #define _WCHAR_T_DEFINED  /* For WINDOWS.H */
  52. typedef unsigned short wchar_t;
  53. #endif
  54. #endif
  55.  
  56. #if !defined(_WINT_T)
  57. typedef wchar_t wint_t;
  58. #define _WINT_T
  59. #endif
  60.  
  61. /* Definition of the file position type
  62. */
  63. typedef long    fpos_t;
  64.  
  65. /* An external reference to _floatconvert (using #pragma extref _floatconvert)
  66.  * forces floating point format conversions to be linked.
  67.  */
  68. extern int _floatconvert;
  69.  
  70. /* Bufferisation type to be used as 3rd argument for "setvbuf" function
  71. */
  72. #define _IOFBF  0
  73. #define _IOLBF  1
  74. #define _IONBF  2
  75.  
  76. /*  "flags" bits definitions
  77. */
  78. #define _F_RDWR 0x0003                  /* Read/write flag       */
  79. #define _F_READ 0x0001                  /* Read only file        */
  80. #define _F_WRIT 0x0002                  /* Write only file       */
  81. #define _F_BUF  0x0004                  /* Malloc'ed Buffer data */
  82. #define _F_LBUF 0x0008                  /* line-buffered file    */
  83. #define _F_ERR  0x0010                  /* Error indicator       */
  84. #define _F_EOF  0x0020                  /* EOF indicator         */
  85. #define _F_BIN  0x0040                  /* Binary file indicator */
  86. #define _F_IN   0x0080                  /* Data is incoming      */
  87. #define _F_OUT  0x0100                  /* Data is outgoing      */
  88. #define _F_TERM 0x0200                  /* File is a terminal    */
  89.  
  90. /* End-of-file constant definition
  91. */
  92. #define EOF (-1)                /* End of file indicator */
  93. #define WEOF (wint_t)(0xFFFF)   /* wide-character end of file indicator */
  94.  
  95. /* Default buffer size use by "setbuf" function
  96. */
  97. #define BUFSIZ  512         /* Buffer size for stdio */
  98.  
  99. /* Size of an arry large enough to hold a temporary file name string
  100. */
  101. #define L_ctermid   5       /* CON: plus null byte */
  102. #define P_tmpdir    ""      /* temporary directory */
  103. #define L_tmpnam    13      /* tmpnam buffer size */
  104.  
  105. /* Constants to be used as 3rd argument for "fseek" function
  106. */
  107. #define SEEK_CUR    1
  108. #define SEEK_END    2
  109. #define SEEK_SET    0
  110.  
  111. /* Number of unique file names that shall be generated by "tmpnam" function
  112. */
  113. #define TMP_MAX     0xFFFF
  114.  
  115.  
  116. #if !defined(__FLAT__)
  117.  
  118. /* Definition of the control structure for streams
  119. */
  120. typedef struct  {
  121.         int             level;          /* fill/empty level of buffer */
  122.         unsigned        flags;          /* File status flags          */
  123.         char            fd;             /* File descriptor            */
  124.         unsigned char   hold;           /* Ungetc char if no buffer   */
  125.         int             bsize;          /* Buffer size                */
  126.         unsigned char   _FAR *buffer;   /* Data transfer buffer       */
  127.         unsigned char   _FAR *curp;     /* Current active pointer     */
  128.         unsigned        istemp;         /* Temporary file indicator   */
  129.         short           token;          /* Used for validity checking */
  130. }       FILE;                           /* This is the FILE object    */
  131.  
  132. /* Number of files that can be open simultaneously
  133. */
  134. #if defined(__STDC__)
  135. #define FOPEN_MAX (_NFILE_ - 2) /* (_NFILE_ - stdaux & stdprn) */
  136. #else
  137. #define FOPEN_MAX (_NFILE_)     /* Able to have 20 files */
  138. #define SYS_OPEN  (_NFILE_)
  139. #endif
  140.  
  141. #define FILENAME_MAX 80
  142.  
  143. /* Standard I/O predefined streams
  144. */
  145.  
  146. #if !defined( _RTLDLL )
  147. extern  FILE    _RTLENTRY _streams[];
  148. extern  unsigned    _RTLENTRY _nfile;
  149.  
  150. #define stdin   (&_streams[0])
  151. #define stdout  (&_streams[1])
  152. #define stderr  (&_streams[2])
  153. #define stdaux  (&_streams[3])
  154. #define stdprn  (&_streams[4])
  155.  
  156. #else
  157.  
  158. #ifdef __cplusplus
  159. extern "C" {
  160. #endif
  161. FILE far * far _RTLENTRY __getStream(int);
  162. #ifdef __cplusplus
  163. }
  164. #endif
  165.  
  166. #define stdin   __getStream(0)
  167. #define stdout  __getStream(1)
  168. #define stderr  __getStream(2)
  169.  
  170. #endif  /* _RTLDLL  */
  171.  
  172. #ifdef __cplusplus
  173. extern "C" {
  174. #endif
  175. void    _RTLENTRY          clearerr(FILE _FAR *__stream);
  176. int     _RTLENTRY _EXPFUNC fclose(FILE _FAR *__stream);
  177. int     _RTLENTRY _EXPFUNC fflush(FILE _FAR *__stream);
  178. int     _RTLENTRY _EXPFUNC fgetc(FILE _FAR *__stream);
  179. int     _RTLENTRY          fgetpos(FILE _FAR *__stream, fpos_t _FAR *__pos);
  180. char   _FAR *_RTLENTRY _EXPFUNC fgets(char _FAR *__s, int __n, FILE _FAR *__stream);
  181. FILE   _FAR *_RTLENTRY _EXPFUNC fopen(const char _FAR *__path, const char _FAR *__mode);
  182. int     _RTLENTRY _EXPFUNC fprintf(FILE _FAR *__stream, const char _FAR *__format, ...);
  183. int     _RTLENTRY _EXPFUNC fputc(int __c, FILE _FAR *__stream);
  184. int     _RTLENTRY _EXPFUNC fputs(const char _FAR *__s, FILE _FAR *__stream);
  185. size_t  _RTLENTRY _EXPFUNC fread(void _FAR *__ptr, size_t __size, size_t __n,
  186.                      FILE _FAR *__stream);
  187. FILE   _FAR *_RTLENTRY _EXPFUNC freopen(const char _FAR *__path, const char _FAR *__mode,
  188.                             FILE _FAR *__stream);
  189. int     _RTLENTRY _EXPFUNC fscanf(FILE _FAR *__stream, const char _FAR *__format, ...);
  190. int     _RTLENTRY _EXPFUNC fseek(FILE _FAR *__stream, long __offset, int __whence);
  191. int     _RTLENTRY          fsetpos(FILE _FAR *__stream, const fpos_t _FAR *__pos);
  192. long    _RTLENTRY _EXPFUNC ftell(FILE _FAR *__stream);
  193. size_t  _RTLENTRY _EXPFUNC fwrite(const void _FAR *__ptr, size_t __size, size_t __n,
  194.                       FILE _FAR *__stream);
  195. char   _FAR *_RTLENTRY     gets(char _FAR *__s);
  196. void    _RTLENTRY          perror(const char _FAR *__s);
  197. int     _RTLENTRY          printf(const char _FAR *__format, ...);
  198. int     _RTLENTRY          puts(const char _FAR *__s);
  199. int     _RTLENTRYF         remove(const char _FAR *__path);
  200. int     _RTLENTRYF _EXPFUNC rename(const char _FAR *__oldname,const char _FAR *__newname);
  201. void    _RTLENTRY _EXPFUNC rewind(FILE _FAR *__stream);
  202. int     _RTLENTRY          scanf(const char _FAR *__format, ...);
  203. void    _RTLENTRY          setbuf(FILE _FAR *__stream, char _FAR *__buf);
  204. int     _RTLENTRY _EXPFUNC setvbuf(FILE _FAR *__stream, char _FAR *__buf,
  205.                                    int __type, size_t __size);
  206. int     _RTLENTRY _EXPFUNC sprintf(char _FAR *__buffer, const char _FAR *__format, ...);
  207. int     _RTLENTRY _EXPFUNC sscanf(const char _FAR *__buffer,
  208.                                   const char _FAR *__format, ...);
  209. char   _FAR *_RTLENTRY _EXPFUNC strerror(int __errnum);
  210. FILE   _FAR *_RTLENTRY _EXPFUNC tmpfile(void);
  211. char   _FAR *_RTLENTRY _EXPFUNC tmpnam(char _FAR *__s);
  212. int     _RTLENTRY _EXPFUNC ungetc(int __c, FILE _FAR *__stream);
  213. int     _RTLENTRY _EXPFUNC vfprintf(FILE _FAR *__stream, const char _FAR *__format,
  214.                                     void _FAR *__arglist);
  215. int     _RTLENTRY _EXPFUNC vfscanf(FILE _FAR *__stream, const char _FAR *__format,
  216.                                    void _FAR *__arglist);
  217. int     _RTLENTRYF         vprintf(const char _FAR *__format, void _FAR *__arglist);
  218. int     _RTLENTRY          vscanf(const char _FAR *__format, void _FAR *__arglist);
  219. int     _RTLENTRY _EXPFUNC vsprintf(char _FAR *__buffer, const char _FAR *__format,
  220.                                     void _FAR *__arglist);
  221. int     _RTLENTRY _EXPFUNC vsscanf(const char _FAR *__buffer, const char _FAR *__format,
  222.                                    void _FAR *__arglist);
  223. int     _RTLENTRYF         unlink(const char _FAR *__path);
  224. int     _RTLENTRY          getc(FILE _FAR *__fp);
  225.  
  226. int     _RTLENTRY          getchar(void);
  227. int     _RTLENTRY          putchar(const int __c);
  228.  
  229. int     _RTLENTRY          putc